package final_wearebatman_view;

import java.awt.Button;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


//generátor stringjét beállító ablak osztálya
public class GeneratorSetWindow extends Dialog implements ActionListener {

    private TextField tf;
    public String data;

    // Ablak a generátor bitjeinek beállításához
    public GeneratorSetWindow(Frame frame, String prevdata) {
        super(frame, "Set Generator", true);
        addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                e.getWindow().dispose();
            }
        });
        setLayout(new FlowLayout());
        tf = new TextField(20);
        tf.setText(prevdata);        
        tf.doLayout();
        data = prevdata;
        add(tf);
        setLocationByPlatform(true);
        Button btnOk = new Button("OK");
        Button btnCancel = new Button("Cancel");
        add(btnOk);
        btnOk.addActionListener(this);
        add(btnCancel);
        btnCancel.addActionListener(this);
        setSize(150, 50);
        pack();
        show();
    }

    //eseményfigyelő
    public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand().equals("Cancel")) {            
            this.setVisible(false);
        }
        if (e.getActionCommand().equals("OK")) {
            data = tf.getText();
            this.setVisible(false);
        }
    }
}
